<?php
/**
  * @author zhenc
  * @time
  * @param 创建帮助文档 https://www.mageplaza.com/magento-2-module-development/create-system-xml-configuration-magento-2.html
  * @return
*/

namespace Mageplaza\HelloWorld\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Store\Model\ScopeInterface;

class Data extends AbstractHelper
{
    protected  $post;
    const XML_PATH_HELLOWORLD = 'helloworld/';
    public function __construct(Context $context,\Mageplaza\HelloWorld\Model\ResourceModel\Post $post)
    {
        $this->post = $post;
        parent::__construct($context);
    }

    public function getConfigValue($field, $storeId = null)
    {
        return $this->scopeConfig->getValue(
            $field, ScopeInterface::SCOPE_STORE, $storeId
        );
    }


    public function getGeneralConfig($code, $storeId = null)
    {

        return $this->getConfigValue(self::XML_PATH_HELLOWORLD .'general/'. $code, $storeId);
    }
    public function  getInsertData($arr)
    {
        if(is_array($arr)){
            return $this->post->getTest($arr);
        }
        return false;
    }

}